package 剑指Offer.easy;

import java.util.LinkedHashMap;
import java.util.Map;

public class 第一个只出现一次的字符 {
    class Solution {
        public char firstUniqChar(String s) {
            char[] chars = s.toCharArray();
            Map<Character, Boolean> map = new LinkedHashMap<>();
            for (int i = 0; i < chars.length; i++) {
                map.put(chars[i], !map.containsKey(chars[i]));
            }
            for (Map.Entry<Character, Boolean> entry : map.entrySet()) {
                if (entry.getValue()) return entry.getKey();
            }
            return ' ';
        }
    }
}
